<?php
$id_category = (isset($this->pageValues['id_category'])) ? $this->pageValues['id_category'] : '';
echo $this->menuBuilder($this->menus, $id_category);
?>
<div class="orange_line" >&nbsp;</div>
<script>
	$(document).ready(function(){
		$('.buys').click(function(){
			var id_product = $(this).attr('value');
			$.ajax({
				type: 'POST',
				url: '<?php echo $this->pageUrl(array('module' => 'tab', 'target' => 'buys'),true); ?>',
				data: {'id_product': id_product},
				success: function(data){}
			});
		});
	});
</script>
<?php echo $this->form;?>
<div class="sort_container">
		<div class="result_detail">
			<?php if(!empty($this->pageValues['form_submitted'])):?>
				<div class="result_container">
					<?php 
						$this->pageValues['item_count'] = $this->paginator->getTotalItemCount();
						$order = array('url','item_count','keyword','category');
						$keys  = array('keyword', 'category');
						echo $this->results($this->form, $keys, $this->pageValues, $order,$this->url);
					?>
					- <a id="reset" href="<?php echo $this->pageUrl(array('module' => 'tab', 'target' => 'index'), true) ?>" class="icon_reset" title="<?php echo $this->translate('Reset')?>"></a>
				</div>
			<?php endif;?>	
			<?php if (!empty($this->breadscrumb)):?>
				<div class="bread-crumb_container">
					<?php echo $this->partial('index/_breadscrumb.phtml', array('breadscrumb' => $this->breadscrumb, 'pageValues' => $this->pageValues));?>
				</div>
			<?php endif;?>
			
		</div>
        
		<div class="switch_layout_and_sort">
            <?php if(!empty($this->store->shopping_cart_setting)): ?>
                <div class="cart_info">
                    <a title="<?php echo $this->translate('SHOPPING_CART');?>" target="_top" href="<?php echo $this->social->pageUrl( array('redirect_url' => $this->pageUrl(array('module' => 'tab', 'target' => 'cart'),true)), $this->id_page);?>" 
                        id="shopping_cart" class="shopping_cart tooltip_label">
                        <span>0</span>
                    </a>
                </div>
            <?php endif;?>
            
			<?php echo $this->partial('index/_switchLayout.phtml', array('pageValues' => $this->pageValues, 'layout_options'=> $this->layout_options));?>
			<?php echo $this->partial('index/_sortProducts.phtml', array('breadscrumb' => $this->breadscrumb, 'pageValues' => $this->pageValues));?>
        </div>
        
</div>
<?php if ( !empty($this->warning) ): ?>    
    <div class="frontend_warning_product_not_found">
        <?php echo $this->translate('FRONTEND_WARNING_NOTFOUND_PRODUCT');?>
    </div>
    <?php $this->warning = NULL;?>
	<br/>
<?php endif;?>  
<?php if (count($this->paginator)): ?>
	<?php if($this->layout == Core_Model_DbTable_Stores::LAYOUT_3xAll):?>
		<?php echo $this->partial('index/_masonry.phtml', array('paginator' => $this->paginator,'pageValues'=>$this->pageValues, 'social' => $this->social)); ?>
	<?php elseif($this->layout == Core_Model_DbTable_Stores::LAYOUT_10xLIST):?>
		<?php echo $this->partial('index/_list.phtml', array('paginator' => $this->paginator,'pageValues'=>$this->pageValues, 'social' => $this->social)); ?>
	<?php else:?>
		<?php echo $this->partial('index/_grid.phtml', array('paginator' => $this->paginator,'pageValues'=>$this->pageValues,'social' => $this->social)); ?>
	<?php endif;?>
	
<?php elseif (empty($this->pageValues['keyword']) && count($this->paginator)<1): ?>
	<br/>
	<div class="sm_message_panel">
		<p class="header"><?php echo $this->translate('MSG_HAVE_NO_PRODUCT_YET'); ?></p>
	</div>
<?php endif; ?>
<?php
	if ($this->layout != Core_Model_DbTable_Stores::LAYOUT_3xAll)
	{
		if (!empty($this->paginator))
		{
			if (sizeof($this->paginator) > 1)
			{
				echo $this->paginationControl($this->paginator, 'Sliding', 'paginatorControl.phtml', array(
					'pageAsQuery' => true,
					'query' => $this->pageValues));
			}
		}
	}
?>
<?php if($this->layout == Core_Model_DbTable_Stores::LAYOUT_3xAll):?>
	<div id="indicator" style="display: none">
		<img id="indicator_img" src="<?php echo STATIC_URL ?>/img/indicator.gif" />
	</div>
<?php endif;?>
<div style="clear:both">&nbsp;</div>
<?php echo $this->partial('index/scrollTop.phtml');?>
<?php if($this->layout == Core_Model_DbTable_Stores::LAYOUT_3xAll):?>
<script>
	$(window).load(function() {
		$(document).ymMasonry({
			'url' : '<?php echo $this->pageUrl(array('target' => 'more', 'page' => null, 'sort' => null, 'layout' => null)); ?>',
			'startPage' : <?php echo $this->startPage;?>,
			'totalPage' : <?php echo sizeof($this->paginator);?>,
			'form_submitted': '<?php echo isset($this->pageValues['form_submitted'])?$this->pageValues['form_submitted']:'0'?>',
			'keyword' : '<?php echo isset($this->pageValues['keyword'])?$this->pageValues['keyword']:''?>',
			'id_category': '<?php echo isset($this->pageValues['id_category'])?$this->pageValues['id_category']:''?>',
			'item_count': '<?php echo $this->paginator->getTotalItemCount()?>',
			'sort': '<?php echo isset($this->pageValues['sort'])?$this->pageValues['sort']:null;?>',
			'layout': '<?php echo $this->layout;?>'
		});
	});
	
	$(document).ajaxStart(function(){
		$('#indicator').show();
	}).ajaxStop(function(){
		$('#indicator').hide();
	});
</script>
<?php endif;?>

<?php if(!empty($this->store->shopping_cart_setting)): ?>
<script type="text/javascript">
    var id_store    = '<?php echo $this->store->id?>';
    
    $(document).ready(function(){
        loadItemsNumber();
    });
    
    $('.tooltip_label').tipsy();
</script>
<?php endif;?>
